<?php

if (!defined('BASEPATH'))
	exit('No direct script access allowed');

class Category_model extends MY_Model {

	var $table = 'category c';

	public function __construct() {
		parent::__construct();
	}

	public function getCategoryAll() {
		$this->db->cache_on();
		$query = $this->db
				->select('c.id,c.name,c.type,a.img imgLink,a2.img imgHover,a3.img imgBanner')
				->from($this->table)
				->join('album a', 'c.link_id=a.id', 'inner')
				->join('album a2', 'c.active_id=a2.id', 'inner')
				->join('album a3', 'c.banner_id=a3.id', 'inner')
				->group_by('c.id')
				->order_by('c.rank desc, c.id asc')
				->get();
		$this->db->cache_off();
		$rows = $query->result_array();
		$data = array();
		if (!empty($rows)) {
			foreach ($rows as $row) {
				$row ['imgLink'] = base_url($row ['imgLink']);
				$row ['imgHover'] = base_url($row ['imgHover']);
				$row ['imgBanner'] = base_url($row ['imgBanner']);
				$data[] = $row;
			}
		}
		return $data;
	}

}
